<?php

App::uses('CrudController', 'Controller');

class TeamLinesController extends CrudController
{
    public $_model = 'TeamLine';

    public function magic($teamId) {
        $this->request->allowMethod('get');
        $this->layout = 'empty';
    }

    protected function getRecords($param) {
        $m = $this->_model;
        $records = $this->$m->getEnableByTeam($param);
        return $records;
    }

    protected function c($model) {
        $m = $this->_model;
        $teamId = $model->group_id;
        $lineId = $model->line_id;
        $exist = $this->$m->existsEnabledByTeamAndLine($teamId, $lineId);
        if ($exist === false) {
            return array(
                'id' => $model->id,
                'team_id' => $teamId,
                'line_id' => $lineId,
                'status' => $m::STATUS_ENABLED
            );
        }
        return false;
    }

    protected function u($model) {
        return array(
            'line_id' => $model->line_id,
        );
    }

}
